import { IPSModelSortable } from '../../ipsmodel-sortable';
import { IPSAppDEAction } from '../../app/dataentity/ipsapp-deaction';
import { IPSAppDEDataImport } from '../../app/dataentity/ipsapp-dedata-import';
import { IPSAppDataEntity } from '../../app/dataentity/ipsapp-data-entity';
import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDEAction } from '../action/ipsdeaction';
import { IPSDEDataImport } from './ipsdedata-import';
import { IPSDEDataImportItem } from './ipsdedata-import-item';
import { IPSSysPFPlugin } from '../../res/ipssys-pfplugin';
import { IPSSysSFPlugin } from '../../res/ipssys-sfplugin';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEDataImportImpl extends PSModelObjectImpl implements IPSDEDataImport, IPSAppDEDataImport, IPSModelSortable {
  get batchSize(): number {
    return this.M.batchSize;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get createDataAccessAction(): string {
    return this.M.createDataAccessAction;
  }

  protected createpsappdeaction: IPSAppDEAction | null = null;

  getCreatePSAppDEAction(): IPSAppDEAction | null {
    if (this.createpsappdeaction != null) return this.createpsappdeaction;
    const value = this.M.getCreatePSAppDEAction;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getParentPSModelObject('app.dataentity.IPSAppDataEntity') as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.createpsappdeaction = ipsappdataentity.findPSAppDEAction(value);
    }
    return this.createpsappdeaction;
  }

  get createPSAppDEAction(): IPSAppDEAction | null {
    return this.getCreatePSAppDEAction();
  }

  getCreatePSAppDEActionMust(): IPSAppDEAction {
    const value = this.getCreatePSAppDEAction();
    if (value == null) {
      throw new Error('未指定建立应用实体行为');
    }
    return value;
  }

  protected createpsdeaction: IPSDEAction | null = null;

  getCreatePSDEAction(): IPSDEAction | null {
    if (this.createpsdeaction != null) return this.createpsdeaction;
    const value = this.M.getCreatePSDEAction;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.createpsdeaction = ipsdataentity.findPSDEAction(value);
    }
    return this.createpsdeaction;
  }

  get createPSDEAction(): IPSDEAction | null {
    return this.getCreatePSDEAction();
  }

  getCreatePSDEActionMust(): IPSDEAction {
    const value = this.getCreatePSDEAction();
    if (value == null) {
      throw new Error('未指定建立数据行为');
    }
    return value;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get extendMode(): 0 | 2 {
    return this.M.extendMode != null ? this.M.extendMode : 0;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  get orderValue(): number {
    return this.M.orderValue != null ? this.M.orderValue : 99999;
  }

  get pOTime(): number {
    return this.M.pOTime != null ? this.M.pOTime : -1;
  }

  protected psdedataimportitems: IPSDEDataImportItem[] | null = null;

  getPSDEDataImportItems(): IPSDEDataImportItem[] | null {
    if (this.psdedataimportitems == null) {
      this.psdedataimportitems = this.fillChildListModel(this.M.getPSDEDataImportItems, 'dataentity.dataimport.IPSDEDataImportItem') as IPSDEDataImportItem[];
    }
    return this.psdedataimportitems;
  }

  get psDEDataImportItems(): IPSDEDataImportItem[] | null {
    return this.getPSDEDataImportItems();
  }

  findPSDEDataImportItem(objKey: any): IPSDEDataImportItem | null {
    return this.getPSModel5('dataentity.dataimport.IPSDEDataImportItem', this.getPSDEDataImportItems(), objKey) as IPSDEDataImportItem;
  }

  protected pssyspfplugin: IPSSysPFPlugin | null = null;

  getPSSysPFPlugin(): IPSSysPFPlugin | null {
    if (this.pssyspfplugin != null) return this.pssyspfplugin;
    const value = this.M.getPSSysPFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyspfplugin = this.getPSModel4('res.IPSSysPFPlugin', value, 'getPSSysPFPlugin') as IPSSysPFPlugin;
    return this.pssyspfplugin;
  }

  get psSysPFPlugin(): IPSSysPFPlugin | null {
    return this.getPSSysPFPlugin();
  }

  getPSSysPFPluginMust(): IPSSysPFPlugin {
    const value = this.getPSSysPFPlugin();
    if (value == null) {
      throw new Error('未指定前端扩展插件');
    }
    return value;
  }

  protected pssyssfplugin: IPSSysSFPlugin | null = null;

  getPSSysSFPlugin(): IPSSysSFPlugin | null {
    if (this.pssyssfplugin != null) return this.pssyssfplugin;
    const value = this.M.getPSSysSFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyssfplugin = this.getPSModel4('res.IPSSysSFPlugin', value, 'getPSSysSFPlugin') as IPSSysSFPlugin;
    return this.pssyssfplugin;
  }

  get psSysSFPlugin(): IPSSysSFPlugin | null {
    return this.getPSSysSFPlugin();
  }

  getPSSysSFPluginMust(): IPSSysSFPlugin {
    const value = this.getPSSysSFPlugin();
    if (value == null) {
      throw new Error('未指定后台扩展插件');
    }
    return value;
  }

  get updateDataAccessAction(): string {
    return this.M.updateDataAccessAction;
  }

  protected updatepsappdeaction: IPSAppDEAction | null = null;

  getUpdatePSAppDEAction(): IPSAppDEAction | null {
    if (this.updatepsappdeaction != null) return this.updatepsappdeaction;
    const value = this.M.getUpdatePSAppDEAction;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getParentPSModelObject('app.dataentity.IPSAppDataEntity') as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.updatepsappdeaction = ipsappdataentity.findPSAppDEAction(value);
    }
    return this.updatepsappdeaction;
  }

  get updatePSAppDEAction(): IPSAppDEAction | null {
    return this.getUpdatePSAppDEAction();
  }

  getUpdatePSAppDEActionMust(): IPSAppDEAction {
    const value = this.getUpdatePSAppDEAction();
    if (value == null) {
      throw new Error('未指定更新应用实体行为');
    }
    return value;
  }

  protected updatepsdeaction: IPSDEAction | null = null;

  getUpdatePSDEAction(): IPSDEAction | null {
    if (this.updatepsdeaction != null) return this.updatepsdeaction;
    const value = this.M.getUpdatePSDEAction;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.updatepsdeaction = ipsdataentity.findPSDEAction(value);
    }
    return this.updatepsdeaction;
  }

  get updatePSDEAction(): IPSDEAction | null {
    return this.getUpdatePSDEAction();
  }

  getUpdatePSDEActionMust(): IPSDEAction {
    const value = this.getUpdatePSDEAction();
    if (value == null) {
      throw new Error('未指定更新数据行为');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get defaultMode(): boolean {
    return this.M.defaultMode != null ? this.M.defaultMode : false;
  }

  get enableBackend(): boolean {
    return this.M.enableBackend;
  }

  get enableFront(): boolean {
    return this.M.enableFront;
  }

  get ignoreError(): boolean {
    return this.M.ignoreError;
  }

  get valid(): boolean {
    return this.M.valid != null ? this.M.valid : true;
  }

  get cls(): string {
    return 'PSDEDataImportImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'IPSModelSortable' || cls == 'app.dataentity.IPSAppDEDataImport' || cls == 'app.dataentity.IPSAppDataEntityObject' || cls == 'dataentity.dataimport.IPSDEDataImport') return true;
    return super.instanceof(cls);
  }
}
